package com.dd.shop4j.console.goods.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dd.shop4j.goods.mapper.GoodsAttrDetailsMapper;
import com.dd.shop4j.goods.mapper.GoodsAttrMapper;
import com.dd.shop4j.goods.mapper.GoodsInfoAttrDetailMapper;
import com.dd.shop4j.goods.model.GoodsAttr;
import com.dd.shop4j.goods.model.GoodsAttrDetails;
import com.dd.shop4j.goods.model.GoodsInfoAttrDetail;

/**
 * 商品属性业务类
 * 
 * <ul style="list-style: decimal;">
 *   <li>获取所有属性</li>
 *   <li>根据属性id获取所有属性类型</li>
 *   <li>根据商品id得到商品属性信息列表</li>
 * </ul>
 * @author Administrator
 *
 */
@Service
public class GoodsAttrManagerService {

	@Resource private GoodsAttrMapper goodsAttrMapper;
	@Resource private GoodsAttrDetailsMapper goodsAttrDetailsMapper;
	@Resource private GoodsInfoAttrDetailMapper goodsInfoAttrDetailMapper;
	
	/**
	 * 获取所有属性
	 * @return 属性列表
	 */
	public List<GoodsAttr> getAllGoodsAttrs() {
		return goodsAttrMapper.queryBySelective(null);
	}
	
	/**
	 * 根据属性id获取所有属性类型
	 * @param attrId 属性id
	 * @return 属性详情列表
	 */
	public List<GoodsAttrDetails> getAttrDetailsByAttrId(Integer attrId) {
		GoodsAttrDetails entity = new GoodsAttrDetails();
		entity.setAttrId(attrId);
		return goodsAttrDetailsMapper.queryBySelective(entity);
	}
	
	/**
	 * 根据商品id得到商品属性信息列表
	 * @param goodId 商品id
	 * @return
	 */
	public List<GoodsInfoAttrDetail> getGoodsInfoAttrDetailsByGoodId(Integer goodId) {
		GoodsInfoAttrDetail entity = new GoodsInfoAttrDetail();
		entity.setGoodId(goodId);
		return goodsInfoAttrDetailMapper.queryBySelective(entity);
	}
	
}
